package com.wdt.data.util;


import org.springframework.util.DigestUtils;

/**
 * 生成Token的工具类
 */
public class TokenProccessor {

    /**
     * 生成token
     * @param appId
     * @param appSecret
     * @return
     */
    public static String getToken(String appId, String appSecret) {
        long timestamp = System.currentTimeMillis();
        String key = DigestUtils.md5DigestAsHex((appId+timestamp).getBytes());
        String Secret = DigestUtils.md5DigestAsHex(appSecret.getBytes());
        String token = key.substring(key.length() - 6, key.length()) + Secret.substring(Secret.length() - 6, Secret.length());
        return token;
    }

    /**
     * 验证token
     * @param token
     * @param companyCode
     * @return
     */
    public static boolean verify(String token,String companyCode) {

        return true;
    }

    public static void main(String[] args) {
        System.out.println(getToken("123456", "sfad48784"));
//        611d7a566fc2000a
//        97a7a9f71aa3
    }

}